﻿using AutoMapper;
using FlyingHat.Core.Entities;
using FlyingHat.Model.Models;
using FlyingHat.Office.Import;
using Microsoft.Extensions.DependencyInjection;

namespace FlyingHat.Extensions.ServiceExtensions
{
    /// <summary>
    /// 映射
    /// </summary>
    public static class AutoMapperService
    {
        public static void AddAutoMapperService(this IServiceCollection services)
        {
            services.AddAutoMapper(typeof(CustomProfile));
        }
    }
    public class CustomProfile : Profile
    {
        /// <summary>
        /// 配置构造函数，用来创建关系映射
        /// </summary>
        public CustomProfile()
        {
            CreateMap<User, UserModel>().ReverseMap();
            CreateMap<User, Student>().ReverseMap();
            CreateMap<Classification, ClassificationModel>().ReverseMap();
            CreateMap<Library, LibraryModel>().ReverseMap();
            CreateMap<Bookshelf, BookshelfModel>().ReverseMap();
            CreateMap<Bookshelf, ModifyLibraryModel>().ReverseMap();
            CreateMap<Book, BookKeyModel>().ReverseMap();
            CreateMap<Book, BookModel>().ReverseMap();

        }
    }
}
